package requests

import (
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type ChatRequest struct {
	// Name        string `valid:"name" form:"name"`
	// Description string `valid:"description" form:"description,omitempty"`
	// FIXME()
}

type ChatsQueryRequest struct {
	LatestId uint64 `valid:"latest_id" form:"latest_id,omitempty" json:"latest_id"`
	Limit    int    `valid:"limit" form:"limit,omitempty" json:"limit" default:"10"`
}

func ChatsQuery(data interface{}, c *gin.Context) map[string][]string {

	rules := govalidator.MapData{
		"latest_id": []string{"numeric"},
		"limit":     []string{"required", "numeric"},
	}

	messages := govalidator.MapData{
		"latest_id": []string{"numeric:最新记录ID必须是数字"},
		"limit":     []string{"numeric:查询条数必须是数字"},
	}

	return validate(data, rules, messages)
}
func ChatSave(data interface{}, c *gin.Context) map[string][]string {

	rules := govalidator.MapData{
		// "name":        []string{"required", "min_cn:2", "max_cn:8", "not_exists:chats,name"},
		// "description": []string{"min_cn:3", "max_cn:255"},
	}
	messages := govalidator.MapData{
		// "name": []string{
		//     "required:名称为必填项",
		//     "min_cn:名称长度需至少 2 个字",
		//     "max_cn:名称长度不能超过 8 个字",
		//     "not_exists:名称已存在",
		// },
		// "description": []string{
		//     "min_cn:描述长度需至少 3 个字",
		//     "max_cn:描述长度不能超过 255 个字",
		// },
	}
	return validate(data, rules, messages)
}
